#include "myzlog.h"
#include "config.h"
#include <string>
using namespace std;

bool zlog_inited = false;
zlog_category_t *zcat;

// app version
extern std::string app_version();

// 初始化zlog
bool myzlog_init(void)
{
    int rc;
    string conf = config::zlog_config_file;
    rc = zlog_init(conf.c_str());
    if (rc)
    {
        printf("init failed\n");
        return false;
    }

    zcat = zlog_get_category("my_cat");
    if (!zcat)
    {
        printf("get cat fail\n");
        zlog_fini();
        return false;
    }

    zlog_info(zcat, "\n==================zlog init.=start up,build time=%s %s  %s =========================\n",
              __DATE__, __TIME__, app_version().c_str());
    zlog_inited = true;
    return true;
}

void myzlog_drop(void)
{

    zlog_fini();
}